import 'package:flutter/material.dart';
import 'package:mpflutter_template/demo/color_constant.dart';
import 'package:mpflutter_template/demo/icon_config_default.dart';

import 'post_card_widget.dart';
import 'query_card_widget.dart';

class TopHeadPostWidget extends StatelessWidget {
  bool _isTopLeft = true;
  @override
  Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
          color: ColorConstant.ffffffA8,
          borderRadius: BorderRadius.all(Radius.circular(8)),
          border: Border.all(width: 1, color: ColorConstant.white)),
      margin: const EdgeInsets.only(left: 12, right: 12),
      child: StatefulBuilder(builder: (context, setState) {
        return Column(
          children: [
            Row(
              children: [
                GestureDetector(
                  child: Container(
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.start,
                      children: [
                        Container(
                          width: (MediaQuery.of(context).size.width- 24) /2 ,
                          height: 44,
                          decoration: BoxDecoration(
                              color: _isTopLeft
                                  ? ColorConstant.white
                                  : Colors.transparent,
                              borderRadius: BorderRadius.only(
                                  topLeft: Radius.circular(8))),
                          alignment: Alignment.center,
                          child: Stack(
                            alignment: Alignment.bottomLeft,
                            children: [
                              Container(
                                width: 36,
                                height: 6,
                                decoration: BoxDecoration(
                                    gradient: LinearGradient(stops: [
                                      0.0,
                                      1.0
                                    ], colors: [
                                      ColorConstant.ff85cf26,
                                      ColorConstant.ff88d02d
                                    ])),
                              ),
                              Text(
                                "丰巢柜寄快递",
                                style: TextStyle(
                                    fontSize: 16,
                                    fontWeight: FontWeight.bold,
                                    color: ColorConstant.ff333333),
                              )
                            ],
                          ),
                        ),
                        _isTopLeft
                            ? Container(
                          height: 44,
                          width: 25,
                          child: Image.asset(IconAssetsDefault.ivRight),
                        )
                            : Container(width: 0,height: 0,)
                      ],
                    ),
                  ),
                  onTap: () {
                    setState(() {
                      _isTopLeft = !_isTopLeft;
                    });
                  },
                ),
                Container(
                  width: (MediaQuery.of(context).size.width- 24) /2 ,
                  height: 44,
                  decoration: BoxDecoration(
                      color: !_isTopLeft
                          ? ColorConstant.white
                          : Colors.transparent,
                      borderRadius: BorderRadius.only(
                          topRight: Radius.circular(8))),
                  alignment: Alignment.center,
                  child: Stack(
                    alignment: Alignment.bottomLeft,
                    children: [
                      Container(
                        width: 36,
                        height: 6,
                        decoration: BoxDecoration(
                            gradient: LinearGradient(stops: [
                              0.0,
                              1.0
                            ], colors: [
                              ColorConstant.ff85cf26,
                              ColorConstant.ff88d02d
                            ])),
                      ),
                      Text(
                        "查快递",
                        style: TextStyle(
                            fontSize: 16,
                            fontWeight: FontWeight.bold,
                            color: ColorConstant.ff333333),
                      )
                    ],
                  ),
                )
                // GestureDetector(
                //   onTap: () {
                //     setState(() {
                //       _isTopLeft = !_isTopLeft;
                //     });
                //   },
                //   child: Container(
                //     child: Row(
                //       mainAxisAlignment: MainAxisAlignment.start,
                //       children: [
                //         !_isTopLeft
                //             ? Container(
                //           height: 44,
                //           width: 25,
                //           child: Image.asset(IconAssetsDefault.ivLeft),
                //         )
                //             : Container(width: 0,height: 0,),
                //         Container(
                //           width: (MediaQuery.of(context).size.width- 24) /2 ,
                //           height: 44,
                //           decoration: BoxDecoration(
                //               color: !_isTopLeft
                //                   ? ColorConstant.white
                //                   : Colors.transparent,
                //               borderRadius: BorderRadius.only(
                //                   topRight: Radius.circular(8))),
                //           alignment: Alignment.center,
                //           child: Stack(
                //             alignment: Alignment.bottomLeft,
                //             children: [
                //               Container(
                //                 width: 36,
                //                 height: 6,
                //                 decoration: BoxDecoration(
                //                     gradient: LinearGradient(stops: [
                //                       0.0,
                //                       1.0
                //                     ], colors: [
                //                       ColorConstant.ff85cf26,
                //                       ColorConstant.ff88d02d
                //                     ])),
                //               ),
                //               Text(
                //                 "查快递",
                //                 style: TextStyle(
                //                     fontSize: 16,
                //                     fontWeight: FontWeight.bold,
                //                     color: ColorConstant.ff333333),
                //               )
                //             ],
                //           ),
                //         )
                //       ],
                //     ),
                //   ),
                // )
              ],
            ),
            Container(
              padding: const EdgeInsets.only(bottom: 12),
              decoration: BoxDecoration(
                  color: ColorConstant.white,
                  borderRadius: BorderRadius.only(
                      topLeft: _isTopLeft ? Radius.zero : Radius.circular(8),
                      topRight: !_isTopLeft ? Radius.circular(8) : Radius.zero,
                      bottomLeft: Radius.circular(8),
                      bottomRight: Radius.circular(8))),
              child:PostCardWidget(),// _isTopLeft ? PostCardWidget() : QueryCardWidget(),
            )
          ],
        );
      }),
    );
  }
}
